package com.pzr.soccer.crawler.controller;

import com.pzr.soccer.crawler.service.FootballCrawlerService;
import com.pzr.soccer.model.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author pzr
 * @date:2021-12-23-11:06
 * @Description:
 **/
@RestController
@RequestMapping("/crawler")
public class CrawlerController {
    @Autowired
    FootballCrawlerService footballCrawlerService;

    @PostMapping("/scanToday")
    public R<Object> startScanTodayTask(){

        int count=1;
        while (count<=60){
            count++;
            try {
                footballCrawlerService.scanToday();
                Thread.sleep(60*1000);
            }catch (Exception e){
                return R.fail(e.getMessage());
            }
        }
        return R.ok("启动crawler scanToday 成功!");
    }

}
